package com.dg.cuckoo.admin.action.projectInfo;

import com.dg.cuckoo.admin.dto.projectInfo.ProjectImageDto;
import com.dg.cuckoo.admin.service.ProjectImageService;
import com.dg.cuckoo.common.utils.PageModel;
import com.dg.cuckoo.core.BaseController;
import com.dg.cuckoo.core.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 项目信息-项目形象
 */
@RestController
@RequestMapping("/projectInfo/projectImage")
public class ProjectImage extends BaseController {

    @Autowired
    private ProjectImageService service;

    /**
     * 新建
     */
    @PostMapping("save")
    public JsonResult<Void> save(String projectId, ProjectImageDto dto, MultipartFile[] files) throws Exception {
        service.save(projectId,dto,files);
        return new JsonResult<>(OK);
    }

    /**
     * 删除
     */
    @PostMapping("delect")
    public JsonResult<Void> delect(String id){
        service.delect(id);
        return new JsonResult<>(OK);
    }

    /**
     * 分页
     */
    @PostMapping("page/{page}/{pageSize}/{id}")
    public JsonResult<PageModel> page(@PathVariable Integer page, @PathVariable Integer pageSize,@PathVariable String id){
        PageModel data = service.powerfulPage(page, pageSize,id);
        return new JsonResult<>(OK,data);
    }

    /**
     * 点击序号显示内容
     */
    @PostMapping("openSerialInfo/{id}")
    public JsonResult<String> openSerialInfo(@PathVariable String id){
        String data = service.openSerialInfo(id);
        return new JsonResult<>(OK,data);
    }

    /**
     * 点击名称显示文本框
     */
    @PostMapping("openTextNumberInfo")
    public JsonResult<String> openTextNumberInfo(String id){
        String data = service.openTextNumberInfo(id);
        return new JsonResult<>(OK,data);
    }

    /**
     * 编辑
     */
    @PostMapping("updata/{id}")
    public JsonResult<Void> updata(@PathVariable String id,String projectId,ProjectImageDto dto,MultipartFile[]files) throws Exception {
        service.updata(id,projectId,dto,files);
        return new JsonResult<>(OK);
    }

}
